import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { createRouter, createWebHistory, Router } from 'vue-router'

const baseRouter = [
  {
    path: '/',
    name: 'default',
    component: () => import('@/layout/default-layout.vue'),
    children: [
      {
        path: '/',
        name: 'home',
        component: () => import('@/views/home/index.vue'),
      },
    ],
  },
]

const createRouterGuard = (router: Router) => {
  router.beforeEach(async (_to: any, _: any, next: any) => {
    NProgress.start()
    next()
    NProgress.done()
  })
}

NProgress.configure({ showSpinner: false })
const router = createRouter({
  history: createWebHistory('/zcWebsite/'),
  routes: baseRouter,
})
createRouterGuard(router)
export default router
